<%# The license inside this block applies to this file.
	# Copyright 2020 Google Inc.
	# Licensed under the Apache License, Version 2.0 (the "License");
	# you may not use this file except in compliance with the License.
	# You may obtain a copy of the License at
	#
	#     http://www.apache.org/licenses/LICENSE-2.0
	#
	# Unless required by applicable law or agreed to in writing, software
	# distributed under the License is distributed on an "AS IS" BASIS,
	# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	# See the License for the specific language governing permissions and
	# limitations under the License.
-%>
// Requests with consistentHash will error for specific values of
// localityLbPolicy. However, the API will not remove it if the backend
// service is updated to from supporting to non-supporting localityLbPolicy
// (e.g. RING_HASH to RANDOM), which causes an error on subsequent update.
// In order to prevent errors, we ignore any consistentHash returned
// from the API when the localityLbPolicy doesn't support it.
if v, ok :=  res["localityLbPolicy"]; ok {
	lbPolicy := v.(string)
	if lbPolicy != "MAGLEV" && lbPolicy != "RING_HASH" {
		delete(res, "consistentHash")
	}
}

return res, nil
